package com.jp.knowledge.fragment;

import com.jp.knowledge.activity.JpApplicationWebActivity;
import com.jp.knowledge.adapter.SearchRecommentAdapter;
import com.jp.knowledge.model.HeadLineData;
import com.jp.knowledge.model.IModel;
import com.jp.knowledge.my.base.RecycleVAdapter;

import java.util.ArrayList;

/**
 * Created by 528787067@qq.com on 2017/2/16.
 */

public class SearchRecommendFragment extends SearchDetailFragment {

    private int searchType;
    private SearchRecommentAdapter searchRecommentAdapter;

    public void setSearchType(int searchType){
        this.searchType = searchType;
    }

    @Override
    protected void initData() {
        super.initData();

        searchRecommentAdapter = new SearchRecommentAdapter(mContext, new ArrayList<HeadLineData>());
        searchRecommentAdapter.setType(searchType);
        recyclerView.setAdapter(searchRecommentAdapter);
        searchRecommentAdapter.addItemClickListener(new RecycleVAdapter.OnItemClickListener() {
            @Override
            public void itemSelect(int position) {
                onItemClick(position);
            }
        });
    }

    @Override
    public void done(IModel dataModel) {
        super.done(dataModel);
        searchRecommentAdapter.updateAdapter(list);
    }

    private void onItemClick(int position){
        JpApplicationWebActivity.gotoWebActivity(mContext, "details/industryObserversDetail?id="+list.get(position).getId());
    }
}
